<?php 

class M_main extends CI_Model{

	function M_main(){
		parent::__construct();
	}

	function get_menus(){
		if($_SESSION[SESSION_USERID]==='Super Admin')
			$sql="select menu_id,menu_title,menu_icon,menu_active from m_menu where menu_parent=0 AND menu_active='y' order by menu_position asc";
		else
			$sql="select menu_id,menu_title,menu_icon from vu_m_menus where m_usergroup_id='".$_SESSION[SESSION_GROUPID]."' and menu_parent=0  AND menu_active='y' order by menu_position asc ";
		$query=$this->db->query($sql);
		$rs=$query->result_array();
		return $rs;
	}
	
	function get_background(){
		$background="";
		/*$sql="select info_background from tbl_s_info";
		$query=$this->db->query($sql);
		if($query->num_rows()){
			$rs=$query->row();
			$background=$rs->info_background;
		}*/
		return $background;
	}	
	
	
	function get_sub_menus(){
		if($_SESSION[SESSION_USERID]==='Super Admin')
			$sql="select * from m_menu where menu_parent<>0  AND menu_active='y' order by menu_parent,menu_position, menu_group asc";
		else
			$sql="select * from vu_m_menus where m_usergroup_id='".$_SESSION[SESSION_GROUPID]."' and menu_parent<>0 AND menu_active='y' order by menu_parent,menu_group,menu_position asc ";
		$query=$this->db->query($sql);
		$rs=$query->result_array();
		return $rs;
	}
	
	function get_sub_groups(){
		if($_SESSION[SESSION_USERID]==='Super Admin')
			$sql="select distinct menu_group,menu_parent,menu_active from m_menu where menu_parent<>0  AND menu_active='y' order by menu_group,menu_parent asc";
		else
			$sql="select distinct menu_group,menu_parent,menu_active from vu_m_menus where m_usergroup_id='".$_SESSION[SESSION_GROUPID]."' and menu_parent<>0 AND menu_active='y' order by menu_group,menu_parent asc ";
		$query=$this->db->query($sql);
		$rs=$query->result_array();
		return $rs;
	}
	
	
}
?>